//
//  GoodListSectionHeadView.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/9/10.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "GoodListSectionHeadView.h"
#import "GoodListModel.h"

@interface GoodListSectionHeadView ()

@property (nonatomic, strong) UIView *bgView;

@end

@implementation GoodListSectionHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = HexColor(0xffffff);
        self.bgView = [UIView new];
        self.bgView.backgroundColor = HexColor(0xF7F7FA);
        [self addSubview:self.bgView];
    }
    return self;
}

-(void)setTitleArray:(NSArray *)titleArray {
    _titleArray = titleArray;
    [self configUI];
}

- (void)configUI {
    self.bgView.nim_left = 0;
    self.bgView.nim_top = 0;
    self.bgView.nim_width = GoodList_ViewWidth * self.titleArray.count;
    [self.bgView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    __block CGFloat viewHeight = 0;
    [self.titleArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *lab = [UILabel new];
        lab.textColor = HexColor(0x585974);
        lab.font = [UIFont systemFontOfSize:13];
        lab.textAlignment = NSTextAlignmentCenter;
        lab.nim_left = GoodList_ViewWidth * idx;
        lab.nim_top = 15;
        lab.nim_width = GoodList_ViewWidth;
        lab.nim_height = 15;
        lab.text = [NSString stringWithFormat:@"%@",obj];
        [self.bgView addSubview:lab];
        viewHeight = lab.nim_bottom + 15;
    }];
    self.bgView.nim_height = viewHeight;
}

@end
